package com.utheima.a;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class DemoArrayListNames {
    public static void main(String[] args) {
        List<String> one = new ArrayList<>();
        one.add("黄老邪");
        one.add("陈玄风");
        one.add("梅超风");
        one.add("陆乘风");
        one.add("曲灵风");
        one.add("武眠风");
        one.add("冯默风");
        one.add("罗玉风");
        List<String> two = new ArrayList<>();
        two.add("张三丰");
        two.add("宋远桥");
        two.add("俞莲舟");
        two.add("俞岱岩");
        two.add("张松溪");
        two.add("张翠山");
        two.add("殷梨亭");
        two.add("莫声谷");
        //1.第一个队伍只要名字为3个字的成员姓名
        List<String> list = one.stream().filter(s->s.length()==3).collect(Collectors.toList());
        System.out.println(list);
        System.out.println("------------------------------------");
        //2.第一个队伍筛选之后只要前3个人
        one.stream().limit(3).forEach(System.out::println);
        System.out.println("------------------------------------");
        //3.第二个队伍只要姓张的成员姓名
        List<String> list1=two.stream().filter(s->s.startsWith("张")).collect(Collectors.toList());
        System.out.println(list1);
        System.out.println("------------------------------------");
        //4.第二个队伍筛选之后不要前2个人
        two.stream().skip(2).forEach(System.out::println);
        System.out.println("------------------------------------");
        //5.将两个队伍合并为一个队伍
        Stream a=one.stream();
        Stream b=two.stream();
        Stream<String> three= Stream.concat(a,b);
//        three.forEach(System.out::println);
        //6.创建Person对象
        //7.打印整个队伍的Person对象值
        List<String> list2=three.collect(Collectors.toList());
        List<Person> list3=new ArrayList<>();
        for (String s : list2) {
            list3.add(new Person(s));
        }
        System.out.println(list3);
    }
}
